package com.geostar.constructionland.analyse.service.spatiaanalyst.impl;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.geostar.constructionland.analyse.entity.model.AnalyseModel;
import com.geostar.constructionland.analyse.service.spatiaanalyst.AbsJsonParamPostAnalyst;
import com.geostar.constructionland.analyse.service.spatiaanalyst.SptAlyParamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Slf4j
public class CommonJsonParamPostAnalyst extends AbsJsonParamPostAnalyst {
    @Autowired
    private SptAlyParamService sptAlyParamService;
    @Autowired
    private ObjectMapper objectMapper;

    @Override
    public String getQueryParam(AnalyseModel analyseModel) throws Exception {
        /**确定接口参数构造类型**/
        Map<String, Object> requestInfo = sptAlyParamService.getCommonParam(analyseModel);
        try {
            return objectMapper.writeValueAsString(requestInfo);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            return null;
        }
    }
}
